<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pt="http://xmlns.jcp.org/jsf/passthrough">
<f:view>
	<f:metadata>
		<f:viewAction action="#{menuMB.updateMenu(2)}" />
	</f:metadata>
	<ui:composition template="/WEB-INF/templates/defaultLayout.xhtml">


		<!-- Definiendo la cabecera de la pagina -->
		<ui:define name="title">
			<h:outputText value="Cuenta Bancaria" />
		</ui:define>

		<!-- Definiendo el cuerpo de la pagina -->
		<ui:define name="content">

			<h:outputStylesheet library="css" name="main.css" />


			<p:panel header="TRANSACCIONES RECIBIDAS"
				footer="Necesitas confirmar cada transacción para que se efectúe correctamente">
				<div>
					<h:form>
						<div style="margin: 5px;">
							<p:dataTable id="tablaTransaccionesRecibidas" var="transaccion"
								value="#{transaccionBovedaCajaBean.tablaTransasccionesSolicitadas.rows}"
								selectionMode="single" paginatorPosition="bottom"
								selection="#{transaccionBovedaCajaBean.tablaTransasccionesSolicitadas.selectedRow}"
								rowKey="#{transaccion}" rowIndexVar="row" paginator="true"
								rows="10" sortMode="multiple"
								paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
								rowsPerPageTemplate="5,10,15">

								<f:facet name="header">  
						            TRANSACCIONES DE BOVEDA 
						        </f:facet>
								<p:column headerText="Nro" width="5%" style="text-align:center;">
									<h:outputText value="#{row + 1}" />
								</p:column>
								<p:column headerText="Origen">
									<h:outputText
										value="#{transaccion.historialboveda.boveda.denominacion}" />
								</p:column>
								<p:column headerText="Destino">
									<h:outputText
										value="#{transaccion.historialcaja.caja.denominacion}" />
								</p:column>
								<p:column headerText="Moneda">
									<h:outputText
										value="#{transaccion.historialboveda.boveda.tipomoneda.denominacion}" />
								</p:column>
								<p:column headerText="Monto">
									<h:outputText value="#{transaccion.monto}" />
								</p:column>
								<p:column headerText="Fecha">
									<h:outputText
										value="#{transaccionBovedaCajaBean.getStringDate(transaccion.fecha)}" />
								</p:column>
								<p:column headerText="Hora">
									<h:outputText
										value="#{transaccionBovedaCajaBean.getStringTime(transaccion.hora)}" />
								</p:column>
								<p:column headerText="Estado">
									<h:outputText
										value="#{transaccionBovedaCajaBean.getEstadoTransaccion(transaccion.estadosolicitud,transaccion.estadoconfirmacion)}" />
								</p:column>
								<p:column headerText="STATUS" style="text-align: center;">
									<h:panelGroup
										rendered="#{transaccionBovedaCajaBean.getEstadoTransaccion(transaccion.estadosolicitud,transaccion.estadoconfirmacion) == 'Por confirmar'}">
										<p:commandButton value="Confirmar" styleClass="blue"
											actionListener="#{transaccionBovedaCajaBean.confirmarTransaccion(transaccion)}"
											update="tablaTransaccionesRecibidas, :successConfirmationMessage, :failureMessage"
											style="margin:0px;">
											<p:confirm header="Confirmacion" message="¿Está Seguro?"
												icon="ui-icon-alert" />
										</p:commandButton>
										<p:confirmDialog global="true" showEffect="fade"
											hideEffect="explode">
											<p:commandButton value="Si" type="button"
												styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
											<p:commandButton value="No" type="button"
												styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
										</p:confirmDialog>
									</h:panelGroup>
									<h:panelGroup
										rendered="#{transaccionBovedaCajaBean.getEstadoTransaccion(transaccion.estadosolicitud,transaccion.estadoconfirmacion) != 'Por confirmar'}">
										<h:outputText
											value="#{transaccionBovedaCajaBean.getEstadoTransaccion(transaccion.estadosolicitud,transaccion.estadoconfirmacion)}" />
									</h:panelGroup>
								</p:column>
							</p:dataTable>
						</div>
					</h:form>
				</div>
			</p:panel>
			<br />
			<br />
			<p:panel header="TRANSACCIONES ENVIADAS"
				footer="La caja destino debe confirmar la transaccion">
				<div class="buttons">
					<h:form id="formTransEnviadas">
						<div>
							<h:commandButton id="crearTransaccion" value="Crear Transaccion"
								styleClass="action green">
								<f:ajax
									listener="#{transaccionBovedaCajaBean.setDlgCrearTransasccion(true)}"
									render=":dlgCrearTransaccion :formCrearTransaccion"></f:ajax>
							</h:commandButton>
						</div>
					</h:form>
				</div>
				<div>
					<h:form>
						<div style="margin: 5px;">
							<p:dataTable id="tablaTransaccionesEnviadas" var="transaccion"
								value="#{transaccionBovedaCajaBean.tablaTransasccionesEnviadas.rows}"
								selectionMode="single" paginatorPosition="bottom"
								selection="#{transaccionBovedaCajaBean.tablaTransasccionesEnviadas.selectedRow}"
								rowKey="#{transaccion}" rowIndexVar="row" paginator="true"
								rows="10" sortMode="multiple"
								paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
								rowsPerPageTemplate="5,10,15">

								<f:facet name="header">  
						            Transacciones de Caja 
						        </f:facet>
								<p:column headerText="Nro" width="5%" style="text-align:center;">
									<h:outputText value="#{row + 1}" />
								</p:column>
								<p:column headerText="Origen">
									<h:outputText
										value="#{transaccion.historialcaja.caja.denominacion}" />
								</p:column>
								<p:column headerText="Destino">
									<h:outputText
										value="#{transaccion.historialboveda.boveda.denominacion}" />
								</p:column>
								<p:column headerText="Moneda">
									<h:outputText
										value="#{transaccion.historialboveda.boveda.tipomoneda.denominacion}" />
								</p:column>
								<p:column headerText="Monto">
									<h:outputText value="#{transaccion.monto}" />
								</p:column>
								<p:column headerText="Fecha">
									<h:outputText
										value="#{transaccionBovedaCajaBean.getStringDate(transaccion.fecha)}" />
								</p:column>
								<p:column headerText="Hora">
									<h:outputText
										value="#{transaccionBovedaCajaBean.getStringTime(transaccion.hora)}" />
								</p:column>
								<p:column headerText="Estado">
									<h:outputText
										value="#{transaccionBovedaCajaBean.getEstadoTransaccion(transaccion.estadosolicitud,transaccion.estadoconfirmacion)}" />
								</p:column>
								<p:column headerText="STATUS" style="text-align: center;">
									<h:panelGroup
										rendered="#{transaccionBovedaCajaBean.getEstadoTransaccion(transaccion.estadosolicitud,transaccion.estadoconfirmacion) == 'Por confirmar'}">
										<p:commandButton value="Cancelar" styleClass="red"
											actionListener="#{transaccionBovedaCajaBean.cancelarTransaccion(transaccion)}"
											update="tablaTransaccionesEnviadas" style="margin:0px;">
											<p:confirm header="Confirmacion" message="¿Estas Seguro?"
												icon="ui-icon-alert" />
										</p:commandButton>
										<p:confirmDialog global="true" showEffect="fade"
											hideEffect="explode">
											<p:commandButton value="Yes" type="button"
												styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
											<p:commandButton value="No" type="button"
												styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
										</p:confirmDialog>
									</h:panelGroup>
									<h:panelGroup
										rendered="#{transaccionBovedaCajaBean.getEstadoTransaccion(transaccion.estadosolicitud,transaccion.estadoconfirmacion) != 'Por confirmar'}">
										<h:outputText
											value="#{transaccionBovedaCajaBean.getEstadoTransaccion(transaccion.estadosolicitud,transaccion.estadoconfirmacion)}" />
									</h:panelGroup>
								</p:column>
							</p:dataTable>
						</div>
					</h:form>
				</div>
			</p:panel>


			<h:panelGroup id="dlgCrearTransaccion">
				<h:panelGroup
					rendered="#{transaccionBovedaCajaBean.dlgCrearTransasccion}">
					<h:form id="formCrearTransaccion">
						<div class="modal-dialog-bg"
							style="opacity: 0.4; width: 1366px; height: 700px;"></div>
						<div class="modal-dialog p6n-popup"
							style="left: 502px; top: 20px; padding: 10px 42px;">
							<div class="modal-dialog-content ng-binding">
								<div class="p6n-api-consent-screen-inputs">
									<div class="p6n-api-consent-screen-input-section"
										style="margin-top: 10px;">
										<div class="p6n-api-consent-screen-label">BOVEDA DESTINO</div>
										<div>
											<h:selectOneMenu id="cmbBoveda"
												value="#{transaccionBovedaCajaBean.comboBovedas.itemSelected}"
												valueChangeListener="#{transaccionBovedaCajaBean.changeBoveda}"
												required="true" requiredMessage="Seleccione una boveda">
												<f:selectItem itemLabel="--SELECCIONE--" itemValue="" />
												<f:selectItems
													value="#{transaccionBovedaCajaBean.comboBovedas.items.entrySet()}"
													var="val" itemLabel="#{val.value.denominacion}"
													itemValue="#{val.key}" />
												<f:ajax render="detalleTransaccion" execute="@this" />
											</h:selectOneMenu>
										</div>
									</div>
									<div
										class="p6n-api-consent-screen-input-error p6n-api-consent-screen-product-name-error-msg">
										<h:message for="cmbBoveda" />
									</div>
									<div class="p6n-api-consent-screen-input-section"
										style="margin-top: 10px;">
										<div class="p6n-api-consent-screen-label">DETALLE
											TRANSACCION</div>
										<div>
											<h:panelGroup id="detalleTransaccion">
												<table
													style="width: 298px; border: solid 1px #E9E6E6; margin-bottom: 0px; margin: 0 auto;">
													<thead>
														<tr>
															<th><label
																style="font-weight: bold; font-size: 12px;">
																	DENOMINACION</label></th>
															<th><label
																style="font-weight: bold; font-size: 12px;">
																	CANTIDAD</label></th>
															<th><label
																style="font-weight: bold; font-size: 12px;"> SUB
																	TOTAL</label></th>
														</tr>
													</thead>
													<tbody>
														<ui:repeat
															value="#{transaccionBovedaCajaBean.tablaDetalletransaccion.rows}"
															var="detalle">
															<h:panelGroup>
																<tr class="ng-scope">
																	<td><h:outputLabel
																			value="#{detalle.denominacionmoneda.denominacion}" /></td>
																	<td><h:inputText value="#{detalle.cantidad}"
																			style="width: 100px; height: 20px;">
																			<f:ajax event="blur" execute="@this"
																				render="txtSubtotal :formCrearTransaccion:txtTotalTransaccion"></f:ajax>
																		</h:inputText></td>
																	<td><h:outputLabel id="txtSubtotal"
																			value="#{detalle.subtotal}" /></td>
																</tr>
															</h:panelGroup>
														</ui:repeat>
													</tbody>
												</table>
											</h:panelGroup>
										</div>
									</div>
									<div class="p6n-api-consent-screen-input-section"
										style="margin-top: 10px;">
										<div class="p6n-api-consent-screen-label">TOTAL</div>
										<div>
											<h:panelGroup id="txtTotalTransaccion">
												<h:outputLabel
													value="#{transaccionBovedaCajaBean.getTotalTransaccion()}" />
											</h:panelGroup>
										</div>
									</div>
									<br />
								</div>
							</div>
							<div class="modal-dialog-buttons">
								<h:commandButton value="Aceptar"
									action="#{transaccionBovedaCajaBean.createTransaccion()}"
									styleClass="action green" onclick="onSubmitButton();">
								</h:commandButton>
								<h:commandButton value="Cancelar" immediate="true"
									styleClass="action">
									<f:ajax
										listener="#{transaccionBovedaCajaBean.setDlgCrearTransasccion(false)}"
										render=":dlgCrearTransaccion"></f:ajax>
								</h:commandButton>
							</div>
						</div>
					</h:form>
				</h:panelGroup>
			</h:panelGroup>

			<h:panelGroup
				rendered="#{transaccionBovedaCajaBean.successCrearTransaccion}">
				<h:form id="form1">
					<script type="text/javascript">
							window.onload = function test(){
        						document.getElementById('form1:print1').focus();
        					}
    					</script>
					<div class="modal-dialog-bg"
						style="opacity: 0.4; width: 1366px; height: 1002px;"></div>
					<div class="modal-dialog p6n-popup" style="left: 501px; top: 78px;">
						<div class="modal-dialog-title modal-dialog-title-draggable">
							<span class="modal-dialog-title-text">Creación
								Satisfactoria...</span><span class="modal-dialog-title-close"></span>
						</div>
						<p:separator></p:separator>
						<div class="modal-dialog-content ng-binding">

							<h:panelGroup id="voucher">
								<table id="t"
									style="width: 225px; border: solid 0px #E9E6E6; margin-bottom: 0px;">
									<tr style="vertical-align: center;">
										<td colspan="1"
											style="text-align: center; font-weight: bold; font-size: 12px;">
											<p:graphicImage name="logo_coop_voucher.png"
												library="images/logo_coop" />
										</td>
										<td colspan="3"
											style="text-align: left; font-weight: bold; font-size: 9px; vertical-align: middle">
											<h:outputText value="C.A.C." /> <br /> <h:outputText
												style="font-size: 16px;" value="CAJA VENTURA" />
										</td>
									</tr>
									<tr style="vertical-align: center;">
										<td colspan="4"
											style="text-align: center; font-weight: bold; font-size: 11px;">
											<h:outputText value="TRANSACCIÓN CAJA ---> BOVEDA" />
										</td>
									</tr>
									<tr>
										<td colspan="1" style="font-weight: bold; font-size: 10px;">AGENCIA:</td>
										<td colspan="3"
											style="font-size: 11px; font-family: Century Gothic;">#{transaccionBovedaCajaBean.agenciaBean.agencia.denominacion}</td>
									</tr>
									<tr>
										<td colspan="1" style="font-weight: bold; font-size: 10px;">CAJA
											ORIGEN:</td>
										<td colspan="3"
											style="font-size: 11px; font-family: Century Gothic;">#{transaccionBovedaCajaBean.cajaBean.caja.abreviatura}</td>
									</tr>
									<tr>
										<td colspan="1" style="font-weight: bold; font-size: 10px;">BOVEDA
											DESTINO:</td>
										<td colspan="3"
											style="font-size: 11px; font-family: Century Gothic;">#{transaccionBovedaCajaBean.comboBovedas.objectItemSelected.denominacion}</td>
									</tr>
									<tr>
										<td style="width: 80px; font-weight: bold; font-size: 10px;">FECHA:</td>
										<td style="font-size: 11px; font-family: Century Gothic;"><h:outputText
												value="#{transaccionBovedaCajaBean.transaccionbovedacaja.fecha}">
												<f:convertDateTime pattern="dd/MM/yy" />
											</h:outputText></td>
									</tr>
									<tr>
										<td style="font-weight: bold; font-size: 10px;">HORA:</td>
										<td style="font-size: 11px; font-family: Century Gothic;"><h:outputText
												value="#{transaccionBovedaCajaBean.transaccionbovedacaja.hora}">
												<f:convertDateTime dateStyle="full" timeZone="EST"
													type="time" />
											</h:outputText></td>
									</tr>
									<tr>
										<td colspan="1" style="font-weight: bold; font-size: 10px;">MONEDA:</td>
										<td colspan="3"
											style="font-size: 10px; font-family: Century Gothic;">#{transaccionBovedaCajaBean.comboBovedas.objectItemSelected.tipomoneda.denominacion}
											(#{transaccionBovedaCajaBean.comboBovedas.objectItemSelected.tipomoneda.abreviatura})</td>
									</tr>
									<tr>
										<td colspan="4" style="font-size: 1px;">&nbsp;</td>
									</tr>
									<tr>
										<td colspan="2" style="font-weight: bold; font-size: 10px;">IMPORTE:</td>
										<td colspan="2"
											style="font-size: 11px; text-align: right; text-align: right; font-family: Century Gothic;">#{transaccionBovedaCajaBean.comboBovedas.objectItemSelected.tipomoneda.abreviatura}#{transaccionBovedaCajaBean.totalTransaccion}</td>
									</tr>
									<tr>
										<td colspan="2" style="font-weight: bold; font-size: 9px;">ESTADO:</td>
										<td colspan="2"
											style="font-size: 10px; text-align: right; font-family: Century Gothic;"><h:outputText
												value="#{transaccionBovedaCajaBean.transaccionbovedacaja.estadoconfirmacion ?  'CONFIRMADO' : 'NO CONFIRMADO'} " />
										</td>
									</tr>
								</table>
							</h:panelGroup>

						</div>
						<div class="modal-dialog-buttons">
							<h:commandButton value="Imprimir" type="button" id="print1"
								styleClass="action green" icon="ui-icon-print">
								<p:printer target="voucher" />
							</h:commandButton>
							<h:commandButton value="Salir" styleClass="action"
								action="transaccionBoveda?faces-redirect=true"
								immediate="true" />
						</div>
					</div>
				</h:form>
			</h:panelGroup>

		</ui:define>
	</ui:composition>
</f:view>
</html>
